package config

import (
	"bytes"
	_ "embed"
	"os"

	"github.com/spf13/viper"
)

//go:embed development.yaml
var development []byte

//go:embed production.yaml
var production []byte

func InitConfig() {
	viper.SetConfigType("yaml")

	if os.Getenv("ENV") == "production" {
		err := viper.ReadConfig(bytes.NewReader(production))
		if err != nil {
			panic("config error:" + err.Error())
		}
	} else {
		err := viper.ReadConfig(bytes.NewReader(development))
		if err != nil {
			panic("config error:" + err.Error())
		}
	}
}
